<?php  $this->load->view('main_menu_view'); ?>
<script type="text/javascript" src="<?= base_url() ?>/js/tiny_mce/tiny_mce.js"></script>
<script>
tinyMCE.init({
    // General options
    mode : "textareas",
    theme : "advanced",
    plugins : "autolink,lists,spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",

    // Theme options
    theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect",
    theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,insertdate,inserttime,preview,fullscreen",
    theme_advanced_buttons3 : "charmap,del,forecolor,backcolor,emotions",
    
    theme_advanced_toolbar_location : "top",
    theme_advanced_toolbar_align : "left",
    theme_advanced_resizing : true,

    // Skin options
    skin : "o2k7",
    skin_variant : "silver"

   
});


</script>
<script>
$(function() {
	/*$('#tabs').tabs({
	   load: function(event, ui) {
	        $('a', ui.panel).click(function() {
	            $(ui.panel).load();
	            return false;
	        });
	    }
	});*/
	$(document).ready(function(){
		loadCommentsList();		
	});

	function loadCommentsList(){
		$.ajax({
			url: CI.baseUrl + '/index.php/tasks_controller/get_task_comments_json',
			type: 'POST',
			data: {'task_id': '<?= $id ?>'},
			dataType: "json",
			success: function(data){
				loadCommentsListCallback(data);
			},
			error: function(data){
				alert('error');
			}
		});
	}
	
	function loadCommentsListCallback(data){
		var container;
		var headerContainer;
		var headerContent;
		var commentContainer;
		for(var i=0; i<data.length; i++){
			comment = $(document.createElement("div"));
			
			header 	= $(document.createElement("div"))
				.attr({class: 'ui-widget-header'});
			headerContent = $(document.createElement("b"))
				.text("Created by " + data[i].firstname + " " + data[i].lastname + " on " + data[i].created_date);

			
			content = $(document.createElement("div"))
				.attr({class: 'ui-widget-content'})
				.html(data[i].comment);
			comment.appendTo("#comments-list");
			comment.append(header);
			header.append(headerContent);
			comment.append(content);
			if (data[i].attachment  != ""){
				$("#comments-list").append("<a href=" + CI.baseUrl + "/uploads/" + data[i].attachment + " class=ui-widget-content> Attachment: "+ data[i].attachment + "</a>");
				$("#comments-list").append("<br></br>");
			}
		} 
	}});
</script>

<style>
	label{
		display: block;
		font-weight: bold;
	}
</style>
<div id="form_task_detail">
<div class="ui-widget-content">
<div id="content" class="container_12" title="Task information">
	<div class="grid_12">
		<p>
			<label for="detail_subject">Subject</label>
			<span name="detail_subject" id="detail_subject"><?= $subject ?></span>
		</p>
	</div>
	<div class="clear"></div>
	<div class="grid_12">
		<p>
			<label for="detail_description">Description</label>
			<span id="detail_description" name="detail_description" id="detail_description"><?= $description ?></span>
		</p>
	</div>
	<div class="clear"></div>
	<div class="grid_6">
		<p>
			<label for="detail_priority">Priority</label>
			<span id="detail_priority" name="detail_priority"><?= $priority ?></span>
		</p>
	</div>
	<div class="grid_6">
		<p>
			<label for="detail_status">Status</label>
			<span id="detail_status" name="detail_status"><?= $status ?></span>
		</p>
	</div>
	<div class="clear"></div>
	<div class="grid_6">
		<p>
			<label for="detail_completed">% completed</label>
			<span id="detail_completed" name="detail_completed"><?= $percentaje_completed ?></span>
		</p>
	</div>
	<div class="grid_6">
		<p>
			<label for="detail_estimated_hours">Estimated Hours</label>
			<span id="detail_estimated_hours" name="detail_estimated_hours"><?= $estimated_hours ?></span>
		</p>
	</div>
	<div class="clear"></div>
	<div class="grid_6">
		<p>
			<label for="detail_worked_hours">Worked Hours</label>
			<span id="detail_worked_hours" name="detail_worked_hours"><?= $worked_hours ?></span>
		</p>
	</div>
	<div class="grid_6">
		<p>
			<label for="detail_assigned_to">Assigned to</label>
			<span id="detail_assigned_to" name="detail_assigned_to"><?= $assigned_to ?></span>
		</p>
	</div>
	<div class="clear"></div>
	<div class="grid_6">
		<p>
			<label for="detail_sprint">Sprint</label>
			<span id="detail_sprint" name="detail_sprint"><?= $sprint ?></span>
		</p>
	</div>
	<div class="clear"></div>
</div>

<div id="comments" class="container_12">
	<div>
		<?php echo form_open_multipart('index.php/tasks_controller/save_comment');?>
			<div class="grid_12">
				<label for="new-comment">New comment</label>
				<textarea name="comment" id="comment" rows="10" style="width:100%"></textarea>
				<input type="hidden" id="ref_id" name="ref_id" value="<?= $id ?>"/>
				<input type="submit" id="save-comment" name="save-comment" value="Create comment" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only"/>
				<input type="file" name="userfile" size="20" />
				</div>
				<div class="clear"></div>
		</form>
	<h1></h1>
	<label>Comments: </label>
    <h1></h1>
	<div id="comments-list">
	</div>
</div>
</div>
</div>
<?php $this->load->view('includes/footer'); ?>